package com.chen.blue.controller.admin.business;

import com.chen.blue.domain.query.business.ContestApplyActiveQuery;
import com.chen.blue.domain.vo.business.ContestApplyActiveVo;
import com.chen.blue.exception.e.DtoNullException;
import com.chen.blue.result.DataResult;
import com.chen.blue.result.R;
import com.chen.blue.service.business.IContestApplyActiveService;
import com.github.xiaoymin.knife4j.annotations.ApiSort;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * Created By CLT On 2024/5/24.
 */
@SuppressWarnings("all")
@ApiSort(996)
@Api(tags = "申报管理-赛事流程模块")
@Validated
@RestController
@PreAuthorize("hasRole('ROLE_teacher')")
@RequestMapping("/contest/active/user")
public class ContestApplyActiveUserController {

    @Resource
    private IContestApplyActiveService iContestApplyActiveService;

    @ApiOperation(value = "多条件查询竞赛申请", notes = "多条件查询竞赛申请")
    @PostMapping("/query")
    public R<DataResult<List<ContestApplyActiveVo>>> query(@RequestBody ContestApplyActiveQuery contestApplyActiveQuery) throws DtoNullException {

        return R.success(iContestApplyActiveService.queryContestApplyUserActive(contestApplyActiveQuery));

    }

    @ApiOperation(value = "ID查询竞赛申请", notes = "ID查询竞赛申请")
    @GetMapping("/queryById/{id}")
    public R<DataResult<Map<String, Object>>> queryById(@PathVariable("id") Long activeId) throws DtoNullException {

        return R.success(iContestApplyActiveService.queryContestApplyActiveById(activeId));

    }

}
